home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PROGEDIT / 3458A.ZIP / AMAC44A.ZIP / MIS002.QM < prev    next >
Text File  |  1992-06-22  |  22KB  |  473 lines

  1. *                               mis002.qm
  2. *            Miscellaneous Counting and Line Numbering Macros
  3. *                        Written By Tom Hogshead
  4. *                       [ See MISCxx.QM For Use ]
  5. *                                 6/18/92
  6. *  Key    Subfile              Description
  7. * =====  =========      =====================================================
  8. *                       Make File of Numbers 1 to 99, No Leading Zeros:
  9. *  @f2                      - Small version                         ( )   |new
  10. *  @7                       - Longer Version Using @5 Technique           |new
  11. *  @9                   Add Line Numbers  001 to  999 In Col 1
  12. *  @0                   Add Line Numbers 0001 to 9999 In Col 1
  13. *  @3                   Make File of Numbers 0001 to 9999 Ascending
  14. *  @4                   Make File of Numbers 9999 to 0001 Descending
  15. *  @5                   Make File of Numbers  001 to  999 Ascending
  16. *  @6                   Make File of Numbers  999 to  001 Descending
  17. *  @1                   Add Line Numbers 0001 to 9999 In Col 81
  18. *  @2                   Remove Previous Line Numbers Made With @1
  19. *
  20. *  @3   {e:\up\rfr005}--Count Words in a File (Use this)
  21. *  @0   {e:\up\rfr005}--  (Alternate version of rfr005.qm @3)
  22. *  @1   {e:\up\rfr005}--Count Characters in a Block
  23. *  @2   {e:\up\rfr005}--Count Characters in a File EXCLUDING Spaces
  24. *  @4   {e:\up\rfr005}--Count Words in a Block
  25. *  @5   {e:\up\rfr005}--Count Characters In A File INCLUDING Spaces
  26. *  @6   {e:\up\rfr005}--Count Words & Characters in File w/COUNT.EXE
  27. *  @f1  {e:\up\PAGE*} --Number Pages in File Containing 'Page' <space> '-'
  28. *
  29. *       {e:\up\MISC*}   Return To MISCxx.QM
  30. *
  31. *   (Generic) Counting
  32. *
  33. *-- eoi
  34.  
  35. *                          M A C R O S
  36. * --------------------------------------------------------------------------
  37. * @(1) Number Lines in File 0001 To 9999 In Col. 81, Ver #3, QEdit v2.15 Reqd.
  38. * --------------------------------------------------------------------------
  39. * This macro is a versatile macro which can be easily modified and used
  40. * to add line numbers to any column with any desired characters
  41. * preceding the line number as shown in @0.  The maximum lines that can
  42. * be numbered is limited only by available memory.
  43.  
  44. * As written, this macro will number up to 9,999 lines in a file with
  45. * line numbers in column 81 preceded by "Asterisk and Ascii #173 (¡)".
  46. * Previous line numbers may be removed with macro @2.
  47.  
  48. * Speed of inserting line numbers is approximately 40 - 50 lines/sec on
  49. * my 12 mhz AT.  For approximately 10% faster operation, remove the
  50. * line "SETSCREENON SETSCREENOFF".  This macro assumes there is no text
  51. * in col's 81+.
  52.  
  53. * I have modified and used the excellent line numbering line numbering
  54. * algorithm originally written by John Goodman.  Thanks again to John
  55. * for this excellent technique.  It is one of the most creative QEdit
  56. * macro algorithms I have seen.
  57.  
  58. @1          macrobegin
  59.             SETSCREENOFF
  60.             savesettings setinsmode setwordwrapmode togglewordwrap
  61.             unmarkblock dropanchor editfile "NUL" return quit gotoblockbeg
  62. *--- (Insert @2 here to remove previous line numbers)
  63.         DO: begfile onewindow horizontalwindow editfile return dropanchor
  64.             "0123456789" copy begline paste paste paste markcharacter endline
  65.             storescrbuff "1" return unmarkblock prevwindow
  66.             gotocolumn  "81" return "*" #173 "0000 "  cursorleft
  67.   MAINLOOP: nextwindow begfile
  68.       LOOP: delch isendline jfalse INCR  unmarkblock
  69.             SETSCREENON SETSCREENOFF        * Remove this line for speed
  70.             getscrbuff "1" return unmarkblock prevwindow backspace "0"
  71.             cursorleft nextwindow cursordown jump LOOP
  72.       INCR: markcolumn prevwindow backspace copyblock cursordown jfalse END
  73.             gotocolumn return
  74.             getprev 7 jump MAINLOOP
  75.        END: nextwindow quit prevwindow onewindow
  76.             begfile endline unmarkblock restoresettings
  77. *
  78. * 145 bytes Mon  10-28-1991  22:19:27 (TH @1, ver 1)
  79. * 173 bytes Tue  10-29-1991  22:23:15 (TH @1, ver 2)
  80. * 132 bytes Tue  11-12-1991  02:12:40 (TH @1, ver 3)
  81.  
  82. * 
  83. * ----------------------------------------------------------------------
  84. * @(2) Remove Previous Line Numbers Made With @1, QEdit v2.15 Reqd.
  85. * ----------------------------------------------------------------------
  86.  
  87. @2      macrobegin
  88.         SETSCREENOFF
  89. * *--- (Add these lines if needed to @1)
  90.         begfile find "*" #173 return delline return
  91.         jfalse DO  begfile gotocolumn "81" return
  92.         isendline jfalse COL1  begfile
  93.   COL1: unmarkblock markcolumn
  94.         gotoline "9999" return
  95.         cursorright 6 deleteblock
  96.    ODD: Find return "B" return jfalse DO  wordright markword
  97.         gotoblockend markcolumn Find return "B" return
  98.         markcolumn deleteblock jump ODD
  99. * *---
  100.     DO: begfile
  101. *
  102. * 24 bytes Mon  10-28-1991  15:42:18 (TH @2)
  103. * 70 bytes Sat  11-02-1991  10:30:34 (TH @2)
  104.  
  105. * 
  106. * --------------------------------------------------------------------------
  107. * @(3) Make File of Numbers 0001 to 9999 In Ascending Order, QEdit v2.15 Reqd.
  108. * --------------------------------------------------------------------------
  109. * This macro will make a single column of consecutive numbers from 0001
  110. * to 9999 in file $9999#.
  111.  
  112. * Speed of inserting line numbers is approximately 40 - 50 lines/sec on
  113. * my 12 mhz AT.  For approximately 10% faster operation, remove the
  114. * line "SETSCREENON SETSCREENOFF".
  115.  
  116. * I have modified and used the excellent line numbering line numbering
  117. * algorithm originally written by John Goodman.  Thanks again to John
  118. * for this excellent technique.  It is one of the most creative QEdit
  119. * macro algorithms I have seen.
  120.  
  121. @3          macrobegin
  122.             SETSCREENOFF
  123.             savesettings setinsmode setwordwrapmode togglewordwrap
  124.             editfile "$9999#" return
  125.             endline begfile jtrue END
  126.             dupline repeatcmd "9997" return
  127.             unmarkblock dropanchor editfile "NUL" return quit gotoblockbeg
  128.         DO: begfile onewindow horizontalwindow editfile return dropanchor
  129.             "0123456789" copy begline paste paste paste markcharacter endline
  130.             storescrbuff "1" return unmarkblock prevwindow "0000 " cursorleft
  131.   MAINLOOP: nextwindow begfile
  132.       LOOP: delch isendline jfalse INCR  unmarkblock
  133.             SETSCREENON SETSCREENOFF        * Remove this line for speed
  134.             getscrbuff "1" return unmarkblock prevwindow backspace "0"
  135.             cursorleft nextwindow cursordown jump LOOP
  136.       INCR: markcolumn prevwindow backspace copyblock cursordown jfalse END1
  137.             begline getprev 5 jump MAINLOOP
  138.       END1: nextwindow quit prevwindow onewindow
  139.             begfile endline unmarkblock restoresettings
  140.        END:
  141. *
  142. * 121 bytes Fri  12-13-1991  01:42:23 (TH @3)
  143. * 151 bytes Sun  12-15-1991  14:03:54 (TH @3)
  144.  
  145. * 
  146. * --------------------------------------------------------------------------
  147. * @(4) Make File of Numbers 9999 to 0001 In Descending Order, QEdit v2.15 Reqd.
  148. * --------------------------------------------------------------------------
  149. * This macro will make a single column of consecutive numbers from 9999
  150. * to 0001 in file $9999#r.
  151.  
  152. * Speed of inserting line numbers is approximately 40 - 50 lines/sec on
  153. * my 12 mhz AT.  For approximately 10% faster operation, remove the
  154. * line "SETSCREENON SETSCREENOFF".
  155.  
  156. @4          macrobegin
  157.             SETSCREENOFF
  158.             savesettings setinsmode setwordwrapmode togglewordwrap
  159.             editfile "$9999#r" return
  160.             endline begfile jtrue END
  161.             dupline repeatcmd "9996" return
  162.             unmarkblock dropanchor editfile "NUL" return quit gotoblockbeg
  163.         DO: begfile onewindow horizontalwindow editfile return dropanchor
  164.             "9876543210" copy begline paste paste paste markcharacter endline
  165.             storescrbuff "1" return unmarkblock prevwindow "9999 " cursorleft
  166.   MAINLOOP: nextwindow begfile
  167.       LOOP: delch isendline jfalse INCR  unmarkblock
  168.             SETSCREENON SETSCREENOFF        * Remove this line for speed
  169.             getscrbuff "1" return unmarkblock prevwindow
  170.             backspace "9" cursorleft nextwindow cursordown jump LOOP
  171.       INCR: markcolumn prevwindow backspace copyblock cursordown jfalse END1
  172.             begline getprev 5 jump MAINLOOP
  173.       END1: nextwindow quit prevwindow onewindow
  174.             begfile insertline "9999"  begline unmarkblock restoresettings
  175.        END:
  176. *
  177. * 162 bytes Sun  12-15-1991  14:04:53 (TH @4)
  178.  
  179. * 
  180. * --------------------------------------------------------------------------
  181. * @(5) Make File of Numbers 001 to 999 In Ascending Order, QEdit v2.15 Reqd.
  182. * --------------------------------------------------------------------------
  183. * This macro will make a single column of consecutive numbers from 001
  184. * to 999 in file c:\$temp.
  185.  
  186. * Speed of inserting line numbers is approximately 40 - 50 lines/sec on
  187. * my 12 mhz AT.  For approximately 10% faster operation, remove the
  188. * line "SETSCREENON SETSCREENOFF".
  189.  
  190. @5          macrobegin
  191.             SETSCREENOFF
  192.             savesettings setinsmode setwordwrapmode togglewordwrap
  193.             editfile "c:\$temp" return                                   *:18
  194.             endline begfile jtrue END
  195.             dupline repeatcmd "997" return
  196.             unmarkblock dropanchor editfile "NUL" return quit gotoblockbeg
  197.         DO: begfile onewindow horizontalwindow editfile return dropanchor
  198.             "0123456789" copy begline
  199.             paste paste                                                  *:18
  200.             markcharacter endline
  201.             storescrbuff "1" return unmarkblock prevwindow "000 " cursorleft
  202.   MAINLOOP: nextwindow begfile
  203.       LOOP: delch isendline jfalse INCR  unmarkblock
  204.             SETSCREENON SETSCREENOFF        * Remove this line for speed
  205.             getscrbuff "1" return unmarkblock prevwindow backspace "0"
  206.             cursorleft nextwindow cursordown jump LOOP
  207.       INCR: markcolumn prevwindow backspace copyblock cursordown jfalse END1
  208.             begline getprev 4 jump MAINLOOP
  209.       END1: nextwindow quit prevwindow onewindow
  210.             begfile endline unmarkblock restoresettings
  211.        END:
  212. *
  213. * 147 bytes Sun  12-15-1991  14:10:12 (TH @5, #3/796)
  214. * 150 bytes Thu  06-18-1992  14:38:01 (TH @5 changed to c:\$temp)
  215.  
  216. * 
  217. * --------------------------------------------------------------------------
  218. * @(6) Make File of Numbers 999 to 001 In Descending Order, QEdit v2.15 Reqd.
  219. * --------------------------------------------------------------------------
  220. * This macro will make a single column of consecutive numbers from 999
  221. * to 001 in file c:\$temp.
  222.  
  223. * Speed of inserting line numbers is approximately 40 - 50 lines/sec on
  224. * my 12 mhz AT.  For approximately 10% faster operation, remove the
  225. * line "SETSCREENON SETSCREENOFF".
  226.  
  227. @6          macrobegin
  228.             SETSCREENOFF
  229.             savesettings setinsmode setwordwrapmode togglewordwrap
  230.             editfile "c:\$temp" return                                   *:18
  231.             endline begfile jtrue END
  232.             dupline repeatcmd "996" return
  233.             unmarkblock dropanchor editfile "NUL" return quit gotoblockbeg
  234.         DO: begfile onewindow horizontalwindow editfile return dropanchor
  235.             "9876543210" copy begline
  236.             paste paste                                                  *:18
  237.             markcharacter endline
  238.             storescrbuff "1" return unmarkblock prevwindow "999 " cursorleft
  239.   MAINLOOP: nextwindow begfile
  240.       LOOP: delch isendline jfalse INCR  unmarkblock
  241.             SETSCREENON SETSCREENOFF        * Remove this line for speed
  242.             getscrbuff "1" return unmarkblock prevwindow
  243.             backspace "9" cursorleft nextwindow cursordown jump LOOP
  244.       INCR: markcolumn prevwindow backspace copyblock cursordown jfalse END1
  245.             begline getprev 4 jump MAINLOOP
  246.       END1: nextwindow quit prevwindow onewindow
  247.             begfile insertline "999"  begline unmarkblock restoresettings
  248.        END:
  249. *
  250. * 156 bytes Sun  12-15-1991  14:14:19 (TH @6, #3/796)
  251. * 157 bytes Thu  06-18-1992  14:38:34 (TH @6 changed to c:\$temp)
  252.  
  253. * 
  254. * --------------------------------------------------------------------------
  255. * @(7) Make File of Numbers 1 to 99, No Leading Zeros,
  256. *      Alternate Longer Version of @f2, Requires QEdit v2.15
  257. * --------------------------------------------------------------------------
  258. * This macro will make a single column of consecutive numbers from 1
  259. * to 99 in the empty temporary file c:\$temp with *no* leading zeros.
  260.  
  261. @7          macrobegin
  262.             SETSCREENOFF
  263.             savesettings setinsmode setwordwrapmode togglewordwrap
  264.             editfile "c:\$temp" return
  265.             begfile
  266.             unmarkblock
  267.             markline endfile markline
  268.             deleteblock
  269.             dupline 98                                                   *:18
  270.             unmarkblock dropanchor
  271.             editfile "NUL" return quit
  272.             gotoblockbeg
  273.         DO: begfile
  274.             onewindow horizontalwindow
  275.             editfile return
  276.             dropanchor "0123456789" copy begline
  277.             paste                                                        *:18
  278.             markcharacter endline
  279.             storescrbuff "1" return
  280.             unmarkblock prevwindow "00 " cursorleft                      *:17
  281.   MAINLOOP: nextwindow begfile
  282.       LOOP: delch isendline jfalse INCR  unmarkblock
  283.             SETSCREENON SETSCREENOFF        * Remove this line for speed
  284.             getscrbuff "1" return
  285.             unmarkblock
  286.             prevwindow
  287.             backspace "0" cursorleft
  288.             nextwindow cursordown
  289.             jump LOOP
  290.       INCR: markcolumn
  291.             prevwindow
  292.             backspace copyblock
  293.             cursordown jfalse END1
  294.             begline
  295.             getprev getprev                                              *:18
  296.             jump MAINLOOP
  297.       END1: nextwindow
  298.             quit
  299.             prevwindow
  300.             onewindow
  301.             begline                                                      *:17
  302.             unmarkblock markcolumn                                       *:17
  303.             begfile                                                      *:17
  304.             findreplace '0' return ' ' return 'ln' return                *:17
  305.             unmarkblock
  306.             restoresettings
  307.        END:
  308. *
  309. * 161 bytes Wed  06-17-1992  18:10:21 (TH @7, changed @5 *|)
  310. * 157 bytes Thu  06-18-1992  14:42:38 (TH @7 removed unnecessary paste *:)
  311.  
  312. * 
  313. * ----------------------------------------------------------------------
  314. * @(9) Add Line Numbers 001 to 999 in Col 1, QEdit v2.15 Required
  315. * ----------------------------------------------------------------------
  316. * This macro will add line numbers 001 to 999 in file in any file.  I
  317. * have modified and used the excellent line numbering line numbering
  318. * algorithm originally written by John Goodman.  Thanks again to John
  319. * for this excellent technique.  It is one of the most creative QEdit
  320. * macro algorithms I have seen.
  321.  
  322. * 500 41/11
  323.  
  324.  
  325. @9          macrobegin
  326.             SETSCREENOFF
  327.             SetInsMode
  328.             UnmarkBlock BegFile DropAnchor EditFile "NUL" Return Quit
  329.             GotoBlockBeg UnmarkBlock OneWindow HorizontalWindow
  330.             EditFile Return DropAnchor "0123456789" Copy BegLine
  331.             Paste Paste DropAnchor EndLine CursorLeft
  332.             StoreScrBuff "1" Return UnmarkBlock
  333.             PrevWindow ShiftRight "000"
  334.   MAINLOOP: NextWindow BegFile
  335.       LOOP: DelCh EndLine JTrue INCR: GetScrBuff "1" Return UnmarkBlock
  336.             SETSCREENON SETSCREENOFF        * Remove this line for speed
  337.             PrevWindow BackSpace "0" CursorLeft
  338.             NextWindow CursorDown Jump LOOP:
  339.       INCR: BegLine DropAnchor
  340.             PrevWindow BackSpace CopyBlock BegLine CursorDown JFalse END:
  341.             ShiftRight GetPrev GetPrev GetPrev
  342.             Jump MAINLOOP:
  343.        END: NextWindow Quit PrevWindow OneWindow GoToBlockEnd
  344.             BegFile UnmarkBlock
  345. *
  346. * 110 bytes Sat  11-02-1991  10:31:02 (TH @9, to TF #20/252, 2/1/92)
  347. * 113 bytes Sat  02-01-1992  14:24:36 (TH @9, added SETSCREENON|off+4x faster)
  348.  
  349. * 
  350. * ----------------------------------------------------------------------
  351. * @(0) Add Line Number 0001 to 9999 in Col 1, QEdit v2.15 Required
  352. * ----------------------------------------------------------------------
  353. * This macro will add line numbers 0001 to 9999 in file in any file.
  354.  
  355. @0          macrobegin
  356.             SETSCREENOFF
  357.             SaveSettings SetInsMode
  358.             UnmarkBlock BegFile DropAnchor EditFile "NUL" Return Quit
  359.             GotoBlockBeg UnmarkBlock OneWindow HorizontalWindow
  360.             EditFile Return DropAnchor "0123456789" Copy BegLine
  361.             Paste Paste Paste DropAnchor EndLine CursorLeft
  362.             StoreScrBuff "1" Return UnmarkBlock
  363.             PrevWindow ShiftRight "0000"
  364.   MAINLOOP: NextWindow BegFile
  365.       LOOP: DelCh EndLine JTrue INCR: GetScrBuff "1" Return UnmarkBlock
  366.             SETSCREENON SETSCREENOFF        * Remove this line for speed
  367.             PrevWindow BackSpace "0" CursorLeft
  368.             NextWindow CursorDown Jump LOOP:
  369.       INCR: BegLine DropAnchor
  370.             PrevWindow BackSpace CopyBlock BegLine CursorDown JFalse END:
  371.             ShiftRight GetPrev GetPrev GetPrev GetPrev
  372.             Jump MAINLOOP:
  373.        END: NextWindow Quit PrevWindow OneWindow GoToBlockEnd
  374.             BegFile UnmarkBlock
  375. *
  376. * 115 bytes Tue  10-29-1991  17:28:04 (TH @0)
  377. * 118 bytes Sat  02-01-1992  14:26:18 (TH @0, added SETSCREENON|off+4x faster)
  378.  
  379.  
  380. * 
  381. * ----------------------------------------------------------------------
  382. * @(f2) Make File of Numbers 1-99, No Leading Zeros
  383. * ----------------------------------------------------------------------
  384. * This macro will insert numbers 1-99 in ascending order with no
  385. * leading zeros, in an empty temporary file 'c:\$temp'.  Without having
  386. * a macro counting or incrementing function, this macro could be
  387. * modified to simulate 'if/then/count/end at count'.  Un-Comment
  388. * 'closewindow' line at end if Qconfig not set to close window on quit.
  389. * Macro requires QEdit v2.15.
  390.  
  391.  
  392. @f2     macrobegin
  393.         SETSCREENOFF setinsmode
  394.         setautoindentmode toggleindent
  395.         onewindow
  396.         markcolumn                          * Mark pos in starting file
  397.         editfile 'c:\$temp' return quit
  398.         gotoblockend
  399.         editfile 'nul' return quit          * Load/quit nul
  400.         gotoblockend
  401.         prevfile prevfile                   * For correct ring pos       *:
  402.         horizontalwindow                    * Window 2
  403.         editfile return                     * Load nul as next file
  404.         markcharacter
  405.         '1234567890'                        * Insert counting line
  406.         storescrbuff 'c' return             * Store to scratch buff 'c'
  407.         dupline                                                          *:
  408.         cursorup                                                         *:
  409.         shiftright                          * Put's space in col 1
  410.         delch                               * Remove '0' line 1
  411.         cursordown                                                       *:
  412.         unmarkblock
  413.         horizontalwindow                    * Window 3
  414.         editfile 'c:\$temp' return          *
  415.     COUNT:
  416.         prevwindow                          * Window 2
  417.         begline markcolumn
  418.         getprev                             * Get ten's digit line 2 col 1
  419.         cut                                 * Cut count to scrap
  420.     NEXT_TEN:
  421.         nextwindow                          * Window 3
  422.         paste unmarkblock                   * Insert count
  423.         addline                             * Make room for next count
  424.         prevwindow                          * Window 2
  425.         cursorright
  426.         isendline jfalse NOT_EOL            * Test if we need to jump 10
  427.         cursorup begline delch              * Move next ten's to col 1
  428.         isemptyline jtrue QUIT
  429.         cursordown begline
  430.         markcolumn
  431.         getprev                             * Put ten's digit line 2 col 1
  432.         cut                                 * Cut count to scrap
  433.         getscrbuff 'c' return               * Insert new one's line
  434.         unmarkblock                                                      *:
  435.         SETSCREENON SETSCREENOFF            * Remove this line for speed *:
  436.         jump NEXT_TEN
  437.     NOT_EOL:
  438.         cursorleft                          * Re-position after eol test
  439.         nextwindow                          * Window 3
  440.         jump COUNT                          * Count 'till no more count
  441.     QUIT:
  442.         quit                                * Quit nul
  443.         * closewindow                       * Add if no quit window/close
  444.     END:
  445.         nextwindow                          * Window 3
  446.         onewindow
  447.         delline
  448.         begfile
  449.         toggleindent
  450. *
  451. * 142 bytes Wed  06-17-1992  17:33:15 (TH @f2, to All #3/870)
  452. * 143 bytes Thu  06-18-1992  15:04:27 (TH @f2, changed for ring pos)
  453.  
  454.  
  455.  
  456. * 
  457. * (Generic) Counting
  458. * -------------------
  459. * The following can be used for different number of counting digits.
  460. * From Line# development file...
  461.  
  462. *      For every extra digit, must add 'paste, 0, getprev' as follows:
  463. *        #          #            #         #      # Start
  464. *      Digits     Paste's      Getprev's  0's     Chars.           Key
  465. *     --------   -------      ---------- ----     --------        ------
  466. *       2+1=3       1             2        2        00              @7
  467. *       3+1=4       2             3        3        000             @5,6,9
  468. *       4+1=5       3             4        4        0000            @3,4,0
  469. *       4+3=7       3             7        4        #173 0000       @1
  470.  
  471.  
  472.  
  473.